import glcore.graphics.GLGraphics;
import glcore.graphics.TextureManager;
import glcore.view.GLApplication;
import se.tinkerway.bomberman.controller.BombermanFactory;
import se.tinkerway.bomberman.controller.GameController;
import se.tinkerway.bomberman.domain.Bomberman;
import se.tinkerway.bomberman.domain.Position;
import se.tinkerway.bomberman.domain.TileMap;
import se.tinkerway.bomberman.util.TileMapGenerator;
import se.tinkerway.bomberman.view.GLKeyboardInterface;
import se.tinkerway.bomberman.view.GLRenderer;


public class TinkerwayBomberman extends GLApplication {
	private static final int SIZE = 15;
	
	private GameController controller;
	
	private GLRenderer renderer;
	
	private Bomberman bomberman;
	
	private TileMap map;
	
	public TinkerwayBomberman() {
		super("Bomberman", 320, 240, 30);
	}

	@Override
	protected void init() {
		map = TileMapGenerator.generate(SIZE);
		
		bomberman = BombermanFactory.create(map, new Position(2, 2));
		
		controller = new GameController(map, bomberman, 
				new GLKeyboardInterface(this));
		
		renderer = new GLRenderer(map.getSize());
	}

	@Override
	protected void loadTextures(TextureManager tm) {
		
	}

	@Override
	protected void render(GLGraphics g) {
		controller.perform();
		renderer.renderTiles(g, map);
		renderer.renderBomberman(g, bomberman);
	}
	
	public static void main(String[] args) {
		new TinkerwayBomberman();
	}
}
